package com.hqyj.lls.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.hqyj.lls.entity.User;
import com.hqyj.lls.service.UserService;
import com.hqyj.lls.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 测试json
 */

//@Controller
@RestController
@RequestMapping("/json")
public class JSONController {

    @Autowired
    private UserService userService;

//    @RequestMapping("/json1")
//    @ResponseBody
/*    public String test1() throws JsonProcessingException {

        //1.对象
        User user = new User();
        user.setUserId(2);
        user.setUsername("张三");
        user.setPassword("123");

        //2.userList
        return new ObjectMapper().writeValueAsString(userService.selectAll());
    }*/

   /* @RequestMapping("json2")
    public String test2() throws JsonProcessingException {
        return DateUtils.getDateJSON(new Date());
    }*/
}
